{include file="public/head"}

<body>
<div class="subject">
	<div class="subject-h">科目选择</div>
	<div class="subject-list">
		<!-- <div class="subject-item subject-item-active">科目一</div>
        <div class="subject-item">科目二</div>
        <div class="subject-item">科目三</div>
        <div class="subject-item">科目四</div> -->
	</div>
</div>
<div class="phototype">
	<div class="phototype-h">照型选择</div>
	<div class="phototype-list">
		<!-- <div class="phototype-item phototype-item-active">大车B2</div>
        <div class="phototype-item">小车自动挡C1</div>
        <div class="phototype-item">小车手动挡C2</div> -->
	</div>
</div>
<div class="timeSelect">
	<div class="timeSelect-left">时间选择</div>
	<div class="timeSelect-right">
		<div class="phototype-item-active">周一~周六</div>
		<div>周天</div>
	</div>
</div>
<div style="height: 1.2rem;"></div>
<a href="/index/traincar/traincarSure?jzid=3&kmid=2" class="submitCent">
	下一步
</a>
<a href="/index/traincar/traincarSubmit?jzid=3&kmid=2" class="submitCent2">
	下一步
</a>
<script src="__STATIC__/home/js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
<script src="__STATIC__/home/js/swiper.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    $(function () {
//  	跳转参数
    	var oneClassVal="";
    	var twoClassVal="";
        // 切换科目
        $(document).on('click', '.subject-item', function (e) {
        	console.log("打印节点",e);
        	oneClassVal=e.currentTarget.dataset.id;
			$(this).addClass("subject-item-active").siblings().removeClass("subject-item-active");
        	var hrefVal='/index/traincar/traincarSubmit?jzid='+ twoClassVal +'&kmid='+ oneClassVal;
        	var hrefVal2='/index/traincar/traincarSure?jzid='+ twoClassVal +'&kmid='+ oneClassVal;
        	$(".submitCent").attr("href",hrefVal);
        	$(".submitCent2").attr("href",hrefVal2);
        });
        // 切换照型
        $(document).on('click', '.phototype-item', function (e) {
        	twoClassVal=e.currentTarget.dataset.id;
			$(this).addClass("phototype-item-active").siblings().removeClass("phototype-item-active");
        	var hrefVal='/index/traincar/traincarSubmit?jzid='+ twoClassVal +'&kmid='+ oneClassVal;
        	var hrefVal2='/index/traincar/traincarSure?jzid='+ twoClassVal +'&kmid='+ oneClassVal;
        	$(".submitCent").attr("href",hrefVal);
        	$(".submitCent2").attr("href",hrefVal2);
        });
		//切换时间
		$(".timeSelect-right>div").click(function(){
			$(this).addClass("phototype-item-active").siblings().removeClass("phototype-item-active");
            if($(this).index()==1){
            	$(".submitCent").hide();
            	$(".submitCent2").show();
            }else{
            	$(".submitCent").show();
            	$(".submitCent2").hide();
            }
		});
        // 补考类型
        $.ajax({
            type: 'post',
            url: '/index/traincar/selectData',
            success(res) {
            	console.log("数据999",res);
                if (res.code == 1) {
//              	跳转路径中的参数,默认第一个
                	oneClassVal=res.class[0].id;
                	twoClassVal=res.driver[0].id;
                	var hrefVal='/index/traincar/traincarSubmit?jzid='+ twoClassVal +'&kmid='+ oneClassVal;
                	var hrefVal2='/index/traincar/traincarSure?jzid='+ twoClassVal +'&kmid='+ oneClassVal;
                	$(".submitCent").attr("href",hrefVal);
                	$(".submitCent2").attr("href",hrefVal2);
                    var classType = res.class || [];
                    var classTypeHtml = '';
                    classType.forEach(function (item, index) {
                        var active = index == 0 ? "subject-item-active" : '';
                        classTypeHtml += `<div class="subject-item ${active}" data-id="${item.id}">${item.class_name}</div>`;
                    });
                    var driverType = res.driver || [];
                    var driverTypeHtml = '';
                    $('.subject-list').html(classTypeHtml);
                    driverType.forEach(function (item, index) {
                        var active = index == 0 ? "phototype-item-active" : '';
                        driverTypeHtml += `<div class="phototype-item ${active}" data-id="${item.id}">${item.name}</div>`;
                    });
                    $('.phototype-list').html(driverTypeHtml);
                }
            },
            error() {
                console.log('补考类型接口错误');
            }
        })

    });
</script>
</body>

</html>